home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1984 January to June / Ahoy_Magazine_84-Jan-Jun_1984_Double_L.d64 / relative files (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  1KB  |  39 lines

  1. 5 rem--ahoy--feb issue--relative files--prog page 27
  2. 10 print"[147]phone book -- relative file demo":open15,8,15,"i0"
  3. 20 print"setup new file (y/n)?";
  4. 30 geta$:ifa$<>"n"anda$<>"y"then30
  5. 40 ifa$="n"thenprint"no":goto60
  6. 50 print"yes":open3,8,3,"@0:phonefile,l,"+chr$(40):goto100
  7. 60 open7,8,7,"counter,s,r":input#7,n:close7:open3,8,3,"phonefile"
  8. 100 print"[147]choose one:":print"1- enter name, number":print"2- search for name"
  9. 110 print"3- display all entries":print"4- exit"
  10. 120 print"enter choice-->";
  11. 130 geta$:a=val(a$):ifa<1ora>4then130
  12. 140 onagoto200,400,600,800
  13. 200 print"[147]active entries ="n
  14. 205 ifn=255thenprint"no more room in file.":gosub990:goto100
  15. 210 print"enter name, number:":i$="":j$=i$:inputi$,j$:ifi$=""orj$=""then100
  16. 220 iflen(i$)+len(j$)>37thenprint"entry is too long...":goto210
  17. 230 n=n+1:print#15,"p"chr$(3)chr$(n)chr$(0):print#3,i$","j$:goto100
  18. 400 ifn=0thenprint"no entries in file.":gosub990:goto100
  19. 405 print"[147]enter name to search for:":n$="":inputn$:ifn$=""then100
  20. 410 j=0:forx=1ton:print#15,"p"chr$(3)chr$(x)chr$(0):input#3,i$,j$
  21. 415 ifi$<>n$then430
  22. 420 x=n:j=n
  23. 430 next:ifj=0thenprint"not found.":gosub990:goto100
  24. 440 printn$,j$:gosub990:goto100
  25. 600 print"[147]hit f1 to pause and continue"
  26. 610 ifn=0thenprint"no entries in file.":gosub990:goto100
  27. 620 forx=1ton:print#15,"p"chr$(3)chr$(x)chr$(0):input#3,i$,j$:printi$,j$
  28. 625 geta$:ifa$<>"[133]"then630
  29. 627 geta$:ifa$<>"[133]"then627
  30. 630 next:gosub990:goto100
  31. 800 print"[147]exit, are you sure (y/n)? ";
  32. 810 geta$:ifa$<>"n"anda$<>"y"then810
  33. 820 ifa$="n"thenprint"no":goto100
  34. 830 print"yes":open7,8,7,"@0:counter,s,w":print#7,n:close7:input#15,a,b$,c,d
  35. 840 close15:end
  36. 990 print"hit return to continue."
  37. 995 geta$:ifa$<>chr$(13)then995
  38. 999 return
  39.